<template>
  <div>
    <h2>Count组件当前和为：{{ sum }}</h2>
    <h2>当前和放大10倍：{{ bigSum }}</h2>
    <h2>我是{{ name }},今年{{ age }}</h2>
    <h3 style="color: green">person列表总人数是：{{ personList.length }}</h3>
    <select v-model.number="n">
      <option :value="1">1</option>
      <option :value="2">2</option>
      <option :value="3">3</option>
    </select>
    <button @click="increment(n)">++</button>
    <button @click="decrement(n)">--</button>
    <button @click="incrementOdd(n)">当前和为奇数再加</button>
    <button @click="decrementOdd(n)">等2秒再加</button>
  </div>
</template>

<script>
import { mapGetters, mapState, mapMutations, mapActions } from "vuex";
export default {
  name: "Count",
  data() {
    return {
      n: 1,
    };
  },
  computed: {
    ...mapState("countAbout", ["sum", "age", "name"]),
    ...mapState("personAbout", ["personList"]),
    ...mapGetters("countAbout", ["bigSum"]),
  },
  methods: {
    ...mapMutations("countAbout", { increment: "PLUS", decrement: "REDUCE" }),
    ...mapMutations("countAbout", ["PLUS", "REDUCE"]),

    ...mapActions("countAbout", {
      incrementOdd: "plusOdd",
      decrementOdd: "plusWait",
    }),

    ...mapActions("countAbout", ["plusOdd", "plusWait"]),
  },
  mounted() {
    console.log(this.$store);
  },
};
</script>

<style lang="css">
button {
  margin-left: 5px;
}
</style>